<form>
<h1>Recherche de services de professionnels</h1>
</form>
<?php
/**
 * Created by PhpStorm.
 * User: kouyate
 * Date: 28/03/14
 * Time: 14:01
 */
if(!isset($_POST['envoyer'])){
    ?>

    <div class="panel panel-primary" >
        <div class="panel-heading"><b>
                RECHERCHE</b>
        </div>
        <div class="panel-body">
            <form method="post" action="<?php echo SITE.'index/rechercher' ?>">
                <table class="table table-hover">
                    <tr>
                        <th>Rechercher </th>
                        <th>Nom ou Activité</th>
                        <th>Ville ou code postal</th>

                        <th>Validez</th>
                    </tr>
                    <tr>
                        <td>
                            <select name="professionnel" required class="form-control">
                                <!--<option>Fournisseur</option>-->
                                <option>Restaurant</option>
                                <option>Hôtel</option>
                            </select>
                        </td>
                        <td><input type="text" class="form-control" name="nom" placeholder="texte relative à votre recherche"> </td>
                        <td><input type="text" class="form-control" name="ville_codepostal" placeholder="Ville ou code postal"></td>

                        <td><button type="submit" name="envoyer" class="btn btn-primary">
                                <i class="glyphicon glyphicon-search"></i>&nbsp; Rechercher</button> </td>
                    </tr>
                </table>
            </form>
        </div>
        <div class="panel-footer">

        </div>
    </div>
    <a href="<?php echo SITE ?>" class="btn btn-info ">Retourner à l'accueil</a>
<?php
} else {
    if(isset($fournis)){
        ?>
        <div class="panel panel-primary" >
            <div class="panel-heading"><b>
                    Résultat de la recherche de Fournisseurs</b>
            </div>
            <div class="panel-body">
                <table class="table table-hover">
                    <tr>
                        <th>Type de fournisseur</th>
                        <th>Activité</th>
                        <th>Nom entreprise</th>
                        <th>Détails</th>
                    </tr>
                    <?php
                    foreach($fournis as $fourni){
                        ?>
                        <tr>
                            <td><b style="color: green"><?php echo $fourni->type_fournisseur ?></b></td>
                            <td><b style="color: green"><?php echo $fourni->activite_fournisseur ?></b></td>
                            <td><?php echo $fourni->nom_entreprise_fournisseur ?></td>
                            <td><a class="btn btn-primary" href="<?php echo SITE.'index/detailsFournisseur/'.$fourni->id_fournisseur ?>">Détails</a> </td>
                        </tr>
                    <?php
                    }
                    ?>
                </table>
            </div>
        </div>
        <a href="<?php echo SITE.'index/rechercher' ?>" class="btn btn-info ">Nouvelle recherche</a>
    <?php


    } else if(isset($restos)){
        ?>
        <div class="panel panel-primary" >
            <div class="panel-heading"><b>
                    Résultat de la recherche de Restaurateurs</b>
            </div>
            <div class="panel-body">
                <table class="table table-hover">
                    <tr>
                        <th>Nom</th>
                        <th>Description</th>
                        <th>Ville</th>
                        <th>Détails</th>
                    </tr>
                    <?php
                    foreach($restos as $fourni){
                        ?>
                        <tr>
                            <td><b style="color: green"><?php echo $fourni->nom_restaurant ?></b></td>
                            <td><?php echo $fourni->description_restaurant ?></td>
                            <td><?php echo $fourni->ville ?></td>
                            <td><a class="btn btn-primary" href="<?php echo SITE.'index/detailsRestaurant/'.$fourni->id_restaurant ?>">Détails</a> </td>
                        </tr>
                    <?php
                    }
                    ?>
                </table>
            </div>
        </div>
        <a href="<?php echo SITE.'index/rechercher' ?>" class="btn btn-info ">Nouvelle recherche</a>
    <?php
    } else if(isset($hotels)){
        ?>
        <div class="panel panel-primary" >
            <div class="panel-heading"><b>
                    Résultat de la recherche d'Hôtels</b>
            </div>
            <div class="panel-body">
                <table class="table table-hover">
                    <tr>
                        <th>Nom de l'hôtel</th>
                        <th>Description</th>
                        <th>Ville</th>
                        <th>Détails</th>
                    </tr>
                    <?php
                    foreach($hotels as $fourni){
                        ?>
                        <tr>
                            <td><b style="color: green"><?php echo $fourni->nom_hotel ?></b></td>
                            <td><?php echo $fourni->description_hotel ?></td>
                            <td><?php echo $fourni->ville ?></td>
                            <td><a class="btn btn-primary" href="<?php echo SITE.'index/detailsHotel/'.$fourni->id_hotel ?>">Détails</a> </td>
                        </tr>
                    <?php
                    }
                    ?>
                </table>
            </div>
        </div>
        <a href="<?php echo SITE.'index/rechercher' ?>" class="btn btn-info ">Nouvelle recherche</a>
    <?php
    } else {
        $this->render404();
    }
}
?>